namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0098 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.IcmCommittee", "RefType", "dbo.IcmMasLookUp");
            DropIndex("dbo.IcmCommittee", new[] { "RefType" });
            RenameColumn(table: "dbo.IcmCommittee", name: "RefType", newName: "SysProcess_LookUpId");
            CreateTable(
                "dbo.IcmCommitteeGroup",
                c => new
                    {
                        CommitteeGroupId = c.Int(nullable: false, identity: true),
                        RecordStatus = c.String(),
                    })
                .PrimaryKey(t => t.CommitteeGroupId);
            
            AddColumn("dbo.IcmPrePurchaseRequest", "CommitteeGroupId", c => c.Int());
            AddColumn("dbo.IcmPurchaseRequest", "CommitteeGroupId", c => c.Int());
            AddColumn("dbo.IcmCommittee", "CommitteeGroupId", c => c.Int());
            AddForeignKey("dbo.IcmPrePurchaseRequest", "CommitteeGroupId", "dbo.IcmCommitteeGroup", "CommitteeGroupId");
            AddForeignKey("dbo.IcmCommittee", "CommitteeGroupId", "dbo.IcmCommitteeGroup", "CommitteeGroupId");
            AddForeignKey("dbo.IcmCommittee", "SysProcess_LookUpId", "dbo.IcmMasLookUp", "LookUpId");
            AddForeignKey("dbo.IcmPurchaseRequest", "CommitteeGroupId", "dbo.IcmCommitteeGroup", "CommitteeGroupId");
            CreateIndex("dbo.IcmPrePurchaseRequest", "CommitteeGroupId");
            CreateIndex("dbo.IcmCommittee", "CommitteeGroupId");
            CreateIndex("dbo.IcmCommittee", "SysProcess_LookUpId");
            CreateIndex("dbo.IcmPurchaseRequest", "CommitteeGroupId");
            DropColumn("dbo.IcmCommittee", "RefId");
        }
        
        public override void Down()
        {
            AddColumn("dbo.IcmCommittee", "RefId", c => c.Int(nullable: false));
            DropIndex("dbo.IcmPurchaseRequest", new[] { "CommitteeGroupId" });
            DropIndex("dbo.IcmCommittee", new[] { "SysProcess_LookUpId" });
            DropIndex("dbo.IcmCommittee", new[] { "CommitteeGroupId" });
            DropIndex("dbo.IcmPrePurchaseRequest", new[] { "CommitteeGroupId" });
            DropForeignKey("dbo.IcmPurchaseRequest", "CommitteeGroupId", "dbo.IcmCommitteeGroup");
            DropForeignKey("dbo.IcmCommittee", "SysProcess_LookUpId", "dbo.IcmMasLookUp");
            DropForeignKey("dbo.IcmCommittee", "CommitteeGroupId", "dbo.IcmCommitteeGroup");
            DropForeignKey("dbo.IcmPrePurchaseRequest", "CommitteeGroupId", "dbo.IcmCommitteeGroup");
            DropColumn("dbo.IcmCommittee", "CommitteeGroupId");
            DropColumn("dbo.IcmPurchaseRequest", "CommitteeGroupId");
            DropColumn("dbo.IcmPrePurchaseRequest", "CommitteeGroupId");
            DropTable("dbo.IcmCommitteeGroup");
            RenameColumn(table: "dbo.IcmCommittee", name: "SysProcess_LookUpId", newName: "RefType");
            CreateIndex("dbo.IcmCommittee", "RefType");
            AddForeignKey("dbo.IcmCommittee", "RefType", "dbo.IcmMasLookUp", "LookUpId", cascadeDelete: true);
        }
    }
}
